<?php
//$api = "https://api.ip.sb/geoip/106.13.118.119";
$query_id    = isset($_GET['ip']) ? $_GET['ip'] : request()->ip();
$collect_url = "http://ip-api.com/json/" . $query_id . "?lang=zh-CN";
$ip_info     = json_decode(file_get_contents($collect_url), true);
?>
<style>
    .yw-search input{
        padding-right: 100px;
    }
    .yw-search button{
        position: absolute;
        top: 0;
        right: 0;
    }
</style>
<div class="layui-tab layui-tab-brief tool-tab" lay-filter="tool-tab">
    <ul class="layui-tab-title text-center">
        <li class="layui-this">{$tool_info.title}</li>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <div class="layui-row">
                <div class="layui-col-sm12 layui-col-md4 layui-col-md-offset4">
                    <form action="">
                        <div class="yw-search">
                            <input type="text" name="ip" value="{$query_id}" class="layui-input" placeholder="请输入要查询的ip">
                            <button type="submit" class="layui-btn layui-btn-normal"><i class="layui-icon layui-icon-search"></i> 查询</button>
                        </div>
                    </form>
                    <table class="layui-table" lay-size="sm">
                        <tbody>
                        <tr>
                            <td>查询ip</td>
                            <td>{$ip_info.query|default="未知"}</td>
                        </tr>
                        <tr>
                            <td>归属地</td>
                            <td>{$ip_info.country|default=""} {$ip_info.regionName|default=""} {$ip_info.city|default=""}</td>
                        </tr>
                        <tr>
                            <td>经纬度</td>
                            <td>{$ip_info.lon|default=""}/{$ip_info.lat|default=""}</td>
                        </tr>
                        <tr>
                            <td>网络服务提供者(isp)</td>
                            <td>{$ip_info.isp|default="未知"}</td>
                        </tr>
                        <tr>
                            <td>运营商</td>
                            <td>{$ip_info.as|default="未知"}</td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
